#include <cstdio>
#include <algorithm>
#define $( head, x, end ) printf("%s%s:%d%s", head, #x, x, end)

using namespace std;

int main(int argc, char const *argv[])
{
    int s[4], a[4][32], *bag;
    int i, j, k, l, sum, result;
    for (i = 0; i < 4; i++)
    {
        scanf("%d", &s[i]);
    }
    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < s[i]; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    result = 0;
    for (i = 0; i < 4; i++)
    {
        sum = 0;
        for (j = 0; j < s[i]; j++)
        {
            sum += a[i][j];
        }
        bag = new int[sum / 2 + 1];
        for (j = 0; j < sum / 2 + 1; j++)
        {
            bag[j] = 0;
        }
        for (j = 0; j < s[i]; j++)
        {
            for (l = sum / 2; l >= a[i][j]; l--)
            {
                bag[l] = max(bag[l], a[i][j] + bag[l - a[i][j]]);
            }
        }
        result += sum - bag[sum / 2];
    }
    printf("%d", result);    
    return 0;
}
